package com.iwhalecloud.citybrain.flow.platform.manager.common.client;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.Data;
import org.apache.commons.collections4.MapUtils;

/**
 * @author lilh
 * @date 2019-02-18 16:14
 */
@Data
public class HttpStartProcessInstanceDto extends HttpCommandDto {
    private static final long serialVersionUID = -5844934409899078164L;

    private Map<String, Object> flowPassList;

    private Map<String, Object> flowParamList;
    //指定后续节点阅办人信息
    private List<TaskReadDoDto> taskReadDoDtoList;
    //操作人
    private String participantId;


    public HttpStartProcessInstanceDto() {
        this.setCommandCode("startProcessInstance");
    }

    @SuppressWarnings("unchecked")
    @Override
    public void init(Map<String, Object> paramsMap) {
        super.init(paramsMap);
        if (paramsMap.get(FLOW_PASS_LIST_STR) != null) {
            this.flowPassList = (Map) paramsMap.get("FLOW_PASS_LIST");
        }

        if (paramsMap.get(FLOW_PARAM_LIST_STR) != null) {
            this.flowParamList = (Map) paramsMap.get("FLOW_PARAM_LIST");
        }

    }

    @Override
    public Map<String, Object> toMap() {
        Map<String, Object> map = super.toMap();
        map.put("FLOW_PASS_LIST", this.flowPassList);
        map.put("FLOW_PARAM_LIST", this.flowParamList);
        return map;
    }


    public Map<String, Object> getFlowParamObjectMap() {
        Map<String, Object> result = new HashMap<>(16);
        if (MapUtils.isEmpty(this.flowParamList)) {
            return result;
        }
        return this.flowParamList;
    }
}
